IF ls_return-type CA 'EA'.
    MS_DATA-MSG = ls_return-MESSAGE.
    CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ELSE.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
    WAIT = 'X'.
ENDIF.